package com.example.nio.im;

import java.io.IOException;
import java.net.Socket;
import java.util.Date;
import java.util.function.Function;

public class Client {

    public static void main(String[] args) {
        test((a) ->{return "a";},"b");
        new Thread(() -> {
            try {
                Socket socket = new Socket("127.0.0.1", 8888);
                while (true) {
                    try {
                        socket.getOutputStream().write((new Date() + ": hello world").getBytes());
                        Thread.sleep(2000);
                    } catch (Exception e) {
                    }
                }
            } catch (IOException e) {
            }
        }).start();

    }
    private static void test(Function function,String a){
        System.out.println(function.apply(a));
    }
}
